﻿<customWindow:BlackStyleChildWindow x:Class="MediaBrowserSL.RIA.Views.ChildWindowPlayer"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:customWindow="http://www.sebastien-alves.fr/jadeToolsSLWindows"   
           xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
           xmlns:eventToCmd="clr-namespace:JulMar.Siverlight.Helpers.Interactivity;assembly=JulMar.Siverlight.Helpers"
           xmlns:MediaBrowserSL_RIA_CustomControls="clr-namespace:MediaBrowserSL.RIA.Views.CustomControls"
           xmlns:jadeControls="http://www.sebastien-alves.fr/jadeToolsSLControls"
           Title="Player" Width="640" Height="480">

    <controls:ChildWindow.DataContext>
        <Binding Mode="OneWay" Path="PlayerMovies" Source="{StaticResource Locator}"/>
    </controls:ChildWindow.DataContext>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closed">
            <eventToCmd:EventToCommand Command="{Binding CloseWindowCommand}"  />
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <Grid x:Name="LayoutRoot" Margin="2" Background="{StaticResource BckWindow}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="45"/>
        </Grid.RowDefinitions>

        <Grid x:Name="GridMediaElement" Grid.Row="0" Background="Black">
            <MediaElement x:Name="mediaElement" Source="{Binding CurrentMedia.UrlContent}" BufferingTime="0:0:30">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MediaOpened">
                        <eventToCmd:EventToCommand Command="{Binding MediaOpenedCommand}" CommandParameter="{Binding ElementName=mediaElement}" />
                    </i:EventTrigger>
                    <i:EventTrigger EventName="MediaFailed">
                        <eventToCmd:EventToCommand Command="{Binding MediaFailedCommand}" CommandParameter="{Binding}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </MediaElement>

        </Grid>

        <Border Grid.Row="2" Margin="1" CornerRadius="0,0,2,2">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#CC4B5059" Offset="0"/>
                    <GradientStop Color="#CC838C9B" Offset="0.985"/>
                </LinearGradientBrush>
            </Border.Background>

            <Grid Margin="10,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="30"/>
                </Grid.ColumnDefinitions>

                <StackPanel Orientation="Horizontal" Grid.Column="0" >
                    <Button Style="{StaticResource PlayButtonStyle}" Command="{Binding PlayVideoCommand}" Height="24" Width="24"/>
                    <Button Style="{StaticResource PauseButtonStyle}" Command="{Binding PauseVideoCommand}"  Height="24" Width="24" Margin="10,0,0,0"/>
                    <Button Style="{StaticResource StopButtonStyle}" Command="{Binding StopVideoCommand}" Height="24" Width="24" Margin="10,0,0,0"/>
                </StackPanel>

                <StackPanel Orientation="Vertical" Grid.Column="1" Margin="10,0,0,0" VerticalAlignment="Bottom">
                    <Slider Style="{StaticResource TrackSlider}" Maximum="{Binding TotalDuration}" Value="{Binding CurrentPosition, Mode=TwoWay}" VerticalAlignment="Stretch" />
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                        <StackPanel Orientation="Horizontal">
                            <MediaBrowserSL_RIA_CustomControls:MuteButtonControl Height="23" Width="22"/>
                            <Slider Style="{StaticResource VolumeSlider}" Maximum="1" LargeChange="0.5" Value="{Binding Volume, ElementName=mediaElement, Mode=TwoWay}"  Width="80" Height="16" Margin="0" HorizontalAlignment="Left" />
                        </StackPanel>
                        <TextBlock x:Name="ProgressDisplay" Text="{Binding CurrentProgress}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#FFFAF7F7"/>
                    </StackPanel>
                </StackPanel>


                <jadeControls:ImageButton Command="{Binding FullScreenCommand}" Source="/MediaBrowserSL.RIA;Component/Images/maxi.png" 
                                           Grid.Column="2" Width="18" Height="18" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
            </Grid>

        </Border>

    </Grid>
</customWindow:BlackStyleChildWindow>